﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Hangjing.SQLServerDAL;
using Hangjing.Model;
using Hangjing.Common;
namespace wap
{
    public partial class index : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            EAddress daladdress = new EAddress();
            if (!IsPostBack)
            {

                lat.Value = SectionProxyData.GetSetValue(4);
                lng.Value = SectionProxyData.GetSetValue(5);

                string _lat = WebUtility.FixgetCookie("lat");
                string _lng = WebUtility.FixgetCookie("lng");

                string openid = Request["openid"];
                if (openid != null && openid != "")
                {
                    WebUtility.FixsetCookie("openid", openid, 1);
                }

                int cid = HjNetHelper.GetQueryInt("cid", 0);
                if (cid > 0)
                {
                    WebUtility.FixsetCookie("user_cityid", cid.ToString(), 365);
                }

                rptCtiy.DataSource = CacheHelper.GetCityList();
                rptCtiy.DataBind();

                HJlog.toLog("openid=" + openid);

                WeixinUserLocationInfo lastlocaiton = new WeixinUserLocation().GetList(1, 1, "openid='" + base.openid + "' and addtime > '"+DateTime.Now.ToShortDateString()+"'", "addtime", 1).FirstOrDefault();
                if (lastlocaiton != null)
                {
                    lat.Value = lastlocaiton.lat;
                    lng.Value = lastlocaiton.lng;
                    hasloction.Value = "1";

                   
                }


            }
        }
    }
}